<?php

/**
 * interest actions.
 *
 * @package    sf_sandbox
 * @subpackage interest
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class interestActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeMy(sfWebRequest $request)
  {

        ////Проверка на заполненность профайла
  	if(!$this->getUser()->getProfile()->getFullProfile())
  	{
  	 $this->getUser ()->setFlash ( 'error', __('Вы не полностью заполнили профайл') );
  	 $this->redirect('profile/step2');
  	}
        ////
    	if(!$request->getParameter('page'))
  	    {
  	    	$this->page = 1;
  	    }
  	    else 
  	    {
  	    	$this->page=$request->getParameter('page');
  	    }  	
  	    
        $c = new Criteria ( );		
		$c->add( InterestPeer::USER_ID, $this->getUser ()->getAttribute ( 'user_id', null, 'sfGuardSecurityUser' ) );
		$c->addDescendingOrderByColumn ( InterestPeer::ID );
		
		$pager = new sfPropelPager('Interest', sfConfig::get('app_interest_perpage'));
        $pager->setCriteria($c);
        $pager->setPeerMethod('doSelect');        
        $pager->setPage($this->page);
        $pager->init();
        $this->interest = $pager;
		///Кидаем пользователя в layout
	     $this->getRequest()->setAttribute('v', $this->getUser()->getProfile());
		////        
        
  }
  
  public function executeMe(sfWebRequest $request)
  {

        ////Проверка на заполненность профайла
  	if(!$this->getUser()->getProfile()->getFullProfile())
  	{
  	 $this->getUser ()->setFlash ( 'error', __('Вы не полностью заполнили профайл') );
  	 $this->redirect('profile/step2');
  	}
        ////
    	if(!$request->getParameter('page'))
  	    {
  	    	$this->page = 1;
  	    }
  	    else 
  	    {
  	    	$this->page=$request->getParameter('page');
  	    }
  	
        $c = new Criteria ( );		
		$c->add( InterestPeer::INTEREST_ID, $this->getUser ()->getAttribute ( 'user_id', null, 'sfGuardSecurityUser' ) );
		$c->addDescendingOrderByColumn ( InterestPeer::ID );
		
		$pager = new sfPropelPager('Interest', sfConfig::get('app_interest_perpage'));
        $pager->setCriteria($c);
        $pager->setPeerMethod('doSelect');        
        $pager->setPage($this->page);
        $pager->init();
        $this->interest = $pager;
		///Кидаем пользователя в layout
	     $this->getRequest()->setAttribute('v', $this->getUser()->getProfile());
		////            
  }
  
  
	
	
}
